﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Interfaces;
using Cofe.Core.Utils;

namespace Cofe.Core.Property
{
    [Export(typeof(ICofeService))]
    [ServicePriority(ServicePriorityAttribute.DefaultPriority_COFE)]
    public class PropertyCacheUpdater : IPropertyCacheUpdater
    {
        #region Constructor
        
        #endregion

        #region Methods
        public async Task UpdateCache(IPropertyProvider[] allPropertyProviders, IPropertyCache cache)
        {           
            //foreach (var property in allPropertyProviders.GetSupportedProperties())
            //{
            //    PropertyRetrivalOptions options = PropertyUtils.GetPropertyRetrivalOptions(property);
            //    IPropertyGetBehavior getBehavior = PropertyBehaviorManager.FindGetBehavior(options);
                
            //    PropertyPair pp = await getBehavior.GetPropertyAsync(property, allPropertyProviders, options);
            //    await cache.SetPropertyAsync(pp);
            //}
        }

        #endregion

        #region Data

        //private IPropertyDictionary _propertyDictionary = null;
        private IPropertyBehaviorManager _propertyBehaviorManager = null;
        
        #endregion

        #region Public Properties

        public IPropertyBehaviorManager PropertyBehaviorManager
        {
            get { return _propertyBehaviorManager ?? CofeServices.ServiceLocater.FindService<IPropertyBehaviorManager>(); }
            set { _propertyBehaviorManager = value; }
        }
        
        #endregion
    }
}
